import apis from "../services/channelManagerApi";

export default {
  namespace: "channelModel",
  state: {
    msgSourceRecord: {}
  },
  effects: {
    // 保存
    *saveChannel({ payload }, { call }) {
      return yield call(apis.saveChannel, payload);
    },
    // 提交
    *commitChannel({ payload }, { call }) {
      return yield call(apis.commitChannel, payload);
    },
    // 修改
    *modChannel({ payload }, { call }) {
      return yield call(apis.modChannel, payload);
    },
    // 删除
    *delChannel({ payload }, { call }) {
      return yield call(apis.delChannel, payload);
    },
    // 列表
    *channelList({ payload }, { call }) {
      return yield call(apis.channelList, payload);
    },
    // 置顶
    *channelTop({ payload }, { call }) {
      return yield call(apis.channelTop, payload);
    },
    *channelDetail({ payload }, { call }) {
      return yield call(apis.channelDetail, payload);
    },
    // 新建钉钉群列表
    *dingcompanygroup({ payload }, { call }) {
      return yield call(apis.dingcompanygroup, payload);
    },
    // 获取钉钉群列表
    *dingcompanygrouplist({ payload }, { call }) {
      return yield call(apis.dingcompanygrouplist, payload);
    },
    // 删除钉钉群
    *dingcompanygroupdel({ payload }, { call }) {
      return yield call(apis.dingcompanygroupdel, payload);
    }
  },
  reducers: {
    updateState: (state, { payload }) => ({
      ...state,
      ...payload
    })
  }
};
